﻿using Dapper;
using SetSailModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SetSailDal
{
    public class MainDal
    {
        /// <summary>
        /// 查询联运公告
        /// </summary>
        /// <param name="GGLX">公告类型</param>
        /// <returns></returns>
        public static ResultModel<QH_GGTX> Query_LYGG(string GGLX)
        {
            ResultModel<QH_GGTX> result = new ResultModel<QH_GGTX>();
            try
            {
                string sql = string.Format(@"SELECT TOP 1 * 
                                             FROM QH_GGTX a WITH(NOLOCK) 
                                             WHERE a.SCBJ=0 AND a.GGLX='{0}'
                                             ORDER BY a.CJSJ DESC", GGLX);
                using (DBHelper help = new DBHelper())
                {
                    result.Data = help.DbContext.QueryFirstOrDefault<QH_GGTX>(sql);
                }
            }
            catch (Exception ex)
            {
                result.Code = ResultCode.Fail;
                result.Message = ex.Message;
            }
            return result;
        }
    }
}
